package com.authine.cloudpivot.ext.utils.system;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.authine.cloudpivot.ext.constants.AppConst;
import com.authine.cloudpivot.ext.constants.ServiceUrlConst;
import com.authine.cloudpivot.ext.utils.HttpClients;
import com.google.common.collect.Maps;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;

public class OrgInviteCodeUtils {

    /**
     * 根据客户组织ID和供应商组织ID列表 获取该供应商列表中对应客户的平台费率
     *
     * @param customerOrgId 客户组织ID
     * @param vendorOrgIds  供应商组织ID
     * @return key=供应商组织ID  value=平台费率
     */
    public static Map<String, BigDecimal> listPlatformRate(String customerOrgId, Collection<String> vendorOrgIds){
        String url = HttpClients.getUrl(AppConst.SYSTEM_MANAGEMENT, ServiceUrlConst.GET_VENDOR_PLATRATE_BY_CUSTOMER);
        Map<String, Object> param = Maps.newHashMap();
        param.put("customerOrgId", customerOrgId);
        param.put("vendorOrgIds", vendorOrgIds);
        return JSON.parseObject(HttpClients.execute(url, param), new TypeReference<Map<String, BigDecimal>>(){});
    }
}
